package easy;

import java.util.Arrays;

public class Solution_2037 {

    public int minMovesToSeat(int[] seats, int[] students) {

        int[] flags = new int[101];
        for (int seat : seats) {
            flags[seat] += 1;
        }
        for (int student : students) {
            flags[student] -= 1;
        }
        int count = 0, num = 0;
        for (int i = 0; i < flags.length; i++) {
            count += Math.abs(num);
            num += flags[i];
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_2037 model = new Solution_2037();
        System.out.println(model.minMovesToSeat(new int[]{3, 1, 5}, new int[]{2, 7, 4}));
        System.out.println(model.minMovesToSeat(new int[]{4, 1, 5, 9}, new int[]{1, 3, 2, 6}));
        System.out.println(model.minMovesToSeat(new int[]{2, 2, 6, 6}, new int[]{1, 3, 2, 6}));
        System.out.println(model.minMovesToSeat(new int[]{3, 20, 17, 2, 12, 15, 17, 4, 15, 20},
            new int[]{10, 13, 14, 15, 5, 2, 3, 14, 3, 18}));
    }
}
